Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse precise capture bounds #252

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

m4rch3n1ng
Copy link

@m4rch3n1ng m4rch3n1ng commented Feb 18, 2025

fn capture(&self) -> impl Iterator<Item = usize> + use<'_> {}

currently tree-sitter-rust says that the use capture bound is a generic_type type_identifier, but after this it is a precise_capture use.

announced here, documented here and specified here.

@m4rch3n1ng m4rch3n1ng force-pushed the precise-capture-bounds branch from 56e1830 to 489d164 Compare February 22, 2025 14:55
@m4rch3n1ng m4rch3n1ng force-pushed the precise-capture-bounds branch from 489d164 to db24a34 Compare February 22, 2025 15:06
@m4rch3n1ng
Copy link
Author

m4rch3n1ng commented Feb 22, 2025

i realized that my first attempt didn't properly parse empty use<> bounds, and then i forgot that type identifiers are also allowed, but now it should work properly i think.

theoretically speaking this syntax also allows const generic parameters, but i couldn't find a way to disambiguate between these two, so i just left those to be parsed as type_parameter. while it's impossible to disambiguate a use<N, T> and figure out if N is a type or a const parameter, it should be possible to take a good guess for something like use<LEN, Type>, but i don't know how to do that. (apparently that is already actually something that editors do in their own highlights.scm queries.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant